/**
 * @file app_freemodbus_HMI.c
 * @author carl.pan (1586975697@qq.com)
 * @brief 
 * @version 0.1
 * @date 2025-06-29
 * 
 * @copyright Copyright (c) 2025
 * 
 */
#include "app_freemodbus_HMI.h"

#define MB_SLAVE_ADDRESS 0x01

static bool modbusInitFlag = false; 

void ModbusService(void)
{
    if (modbusInitFlag == false)
    {
        eMBInit(MB_RTU, MB_SLAVE_ADDRESS, 0, 115200, MB_PAR_NONE);
        eMBEnable();
        modbusInitFlag = true;
    }
    eMBPoll();
}

void ModbusMasterService_10ms(void)
{
    if (modbusInitFlag == false)
    {
        return;
    }

    uint16_t temp16 = 0;

    usSRegInRegSet(MB_ADDRESS_FINGER_LEFT_STATE, &temp16);
    usSRegInRegSet(MB_ADDRESS_WORKBIN_STATE, &temp16);

    // 获取master给的命令，执行对应动作
    usSRegHoldRegGet(MB_ADDRESS_FINGER_LEFT_CMD, &temp16);
    usSRegHoldRegGet(MB_ADDRESS_WORKBIN_CMD, &temp16);
}



